package api

import (
	"gitee.com/zatto/project/tree/master/vblog/api/apps"
	"gitee.com/zatto/project/tree/master/vblog/api/apps/tag"
	"gitee.com/zatto/project/tree/master/vblog/api/protocol/middleware"
	"github.com/gin-gonic/gin"
)

type handler struct {
	svc tag.Service
}

func (h *handler) Name() string {
	return tag.AppName
}

func (h *handler) Init() error {
	h.svc = apps.GetInternalApp(tag.AppName).(tag.Service)
	return nil
}

// 这个模块的API的前缀: /vblog/api/v1/tags
func (h *handler) RegistryHandler(r gin.IRouter) {
	r.Use(middleware.AuthFunc)
	r.POST("/", h.CreateTag)
	r.DELETE("/:blog_id", h.RemoveTag)
}

func init() {
	apps.RegistryHttp(&handler{})
}
